package cn.car91.activity;


public class UserSelfActivity extends BaseActivity {
/*
    @ViewInject(R.id.user_pic)
	RoundedImageView userPic;
	@ViewInject(R.id.user_name)
	TextView nameText;
	
	@ViewInject(R.id.user_item_self)
	LinearLayout selfItem;
	@ViewInject(R.id.user_item_attention)
	LinearLayout attentionItem;
	@ViewInject(R.id.user_item_exposure)
	LinearLayout exposureItem;
	
	@ViewInject(R.id.list_attention)
	ExpandableListView attentionListView;
	@ViewInject(R.id.list_exposure)
	ExpandableListView exposureListView;
	
	@ViewInject(R.id.user_container)
	LinearLayout containerLayout;
	@ViewInject(R.id.user_container_exposure)
	LinearLayout exposureContainerLayout;
	
	static ImageManager imageManager;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		setContentView(R.layout.activity_user_main);
		super.onCreate(savedInstanceState);
		
		User user = getCar91Application().getUser();
		if(user!=null){
			imageManager = new ImageManager(UserSelfActivity.this, "sdcard/car91/temp/user");
			imageManager.displayImage(getCar91Application().getCenterServerUrl() + "/"+ user.getPic(), userPic, getResources().getDrawable(R.drawable.user_default));
			nameText.setText(user.getName());
		}else{
			finish();
		}
		
		selfItem.setOnClickListener(onItemClickListener);
		attentionItem.setOnClickListener(onItemClickListener);
		exposureItem.setOnClickListener(onItemClickListener);
		
		initAttentionExpandable();
		initExposureExpandable();
	}

	@OnClick(R.id.user_self)
	public void onSelfClick(View view){
		Intent intent = new Intent();
		intent.setClass(UserSelfActivity.this, UserInfoActivity.class);
		startActivity(intent);
	}
	
	private void initAttentionExpandable(){
		List<String> attentionTypes = new ArrayList<String>();
		attentionTypes.add(getResources().getString(R.string.user_center_collection));
		attentionTypes.add(getResources().getString(R.string.user_center_comment));
		List<List<String>> attentions = new ArrayList<List<String>>();
		List<String> attentions_collection = new ArrayList<String>();
		attentions_collection.add(getResources().getString(R.string.user_center_collection_repairshop));
		attentions.add(attentions_collection);
		List<String> attentions_comment = new ArrayList<String>();
		attentions_comment.add(getResources().getString(R.string.user_center_comment_repairshop));
		attentions_comment.add(getResources().getString(R.string.user_center_comment_article));
		attentions_comment.add(getResources().getString(R.string.user_center_comment_exposure));
		attentions.add(attentions_comment);
		MyExpandableListAdapter expandableListAdapter = new MyExpandableListAdapter(UserSelfActivity.this, attentionTypes, attentions);
		attentionListView.setAdapter(expandableListAdapter);
		
		
		attentionListView.setOnChildClickListener(onExpandableChildClickListener);
		attentionListView.setOnGroupExpandListener(new OnGroupExpandListener(){
            @Override
            public void onGroupExpand(int groupPosition) {
                // TODO Auto-generated method stub
                for(int i=0;i<attentionListView.getExpandableListAdapter().getGroupCount();i++){
                    if(groupPosition != i){
                    	attentionListView.collapseGroup(i);
                    }
                }
            }});
	}
	
	private void initExposureExpandable(){
		for (int i = 0; i < exposureContainerLayout.getChildCount(); i++) {
			exposureContainerLayout.getChildAt(i).setOnClickListener(onExposureStateClickListener);
		}
		
	}
	
	private OnClickListener onExposureStateClickListener = new OnClickListener() {
		
		@Override
		public void onClick(View arg0) {
			// TODO Auto-generated method stub
			Intent intent = new Intent();
			intent.setClass(UserSelfActivity.this, ExposureRepairshopActivity.class);
			switch (arg0.getId()) {
			case R.id.user_center_exposure_no:
				intent.putExtra("state", 0);
				break;
			case R.id.user_center_exposure_ing:
				intent.putExtra("state", 1);
				break;
			case R.id.user_center_exposure_success:
				intent.putExtra("state", 2);
				break;
			case R.id.user_center_exposure_error:
				intent.putExtra("state", 3);
				break;
			default:
				break;
			}
			startActivity(intent);
		}
	};
	
	private OnChildClickListener onExpandableChildClickListener = new OnChildClickListener() {
		
		@Override
		public boolean onChildClick(ExpandableListView arg0, View arg1, int arg2,
				int arg3, long arg4) {
			// TODO Auto-generated method stub
			String str = (String) arg0.getExpandableListAdapter().getChild(arg2, arg3);
			Intent intent = new Intent();
			
			if(str.equals(getResources().getString(R.string.user_center_collection_repairshop))){
				intent.setClass(UserSelfActivity.this, CollectionRepairshopActivity.class);
			}
			else if(str.equals(getResources().getString(R.string.user_center_comment_repairshop))){
				intent.setClass(UserSelfActivity.this, UserCommentActivity.class);
				intent.putExtra("type",0);
			}
			else if(str.equals(getResources().getString(R.string.user_center_comment_article))){
				intent.setClass(UserSelfActivity.this, UserCommentActivity.class);
				intent.putExtra("type",1);
			}
			else if(str.equals(getResources().getString(R.string.user_center_comment_exposure))){
				intent.setClass(UserSelfActivity.this, UserCommentActivity.class);
				intent.putExtra("type",2);
			}
			startActivity(intent);
			return false;
		}
	};
	
	private OnClickListener onItemClickListener = new OnClickListener() {
		@Override
		public void onClick(View arg0) {
			// TODO Auto-generated method stub
			changeItem(arg0.getId());
			arg0.setBackgroundColor(getResources().getColor(android.R.color.white));
			((TextView)(((LinearLayout)arg0).getChildAt(0))).setTextColor(getResources().getColor(R.color.theme_color));
			switch (arg0.getId()) {
			case R.id.user_item_self:
				showContainer(R.id.user_container_self);
				break;
			case R.id.user_item_attention:
				showContainer(R.id.user_container_attention);		
				break;
			case R.id.user_item_exposure:
				showContainer(R.id.user_container_exposure);
				break;
			default:
				break;
			}
		}
	};
	
	private void changeItem(int itemid){
		selfItem.setBackgroundColor(getResources().getColor(android.R.color.transparent));
		((TextView)(selfItem.getChildAt(0))).setTextColor(getResources().getColor(android.R.color.white));
		attentionItem.setBackgroundColor(getResources().getColor(android.R.color.transparent));
		((TextView)(attentionItem.getChildAt(0))).setTextColor(getResources().getColor(android.R.color.white));
		exposureItem.setBackgroundColor(getResources().getColor(android.R.color.transparent));
		((TextView)(exposureItem.getChildAt(0))).setTextColor(getResources().getColor(android.R.color.white));
	}
	
	private void showContainer(int layoutid){
		for (int i = 0; i < containerLayout.getChildCount(); i++) {
			containerLayout.getChildAt(i).setVisibility(View.GONE);
		}
		findViewById(layoutid).setVisibility(View.VISIBLE);
	}
	
	@OnClick(R.id.user_back)
	public void onBackClick(View view){
		finish();
	}*/
}
